<?php

class Product_Model extends CI_Model
{
  public $product_id;
  public $product_category_id;
  public $product_user_id;
  public $product_title;
  public $product_description;
  public $product_link;
  public $product_rate;
  public $product_price;
  public $product_content;

  
  public function __construct()
  {
    parent::__construct();
  }

  public function load($id)
  {
    $query = $this->db->get_where('product', array('product_id' => $id));
    $this->product_id = -1;
    foreach ($query->result() as $row)
      {
	$this->product_id = $row->product_id;
	$this->product_category_id = $row->product_category_id;
	$this->product_user_id = $row->product_user_id;
	$this->product_title = $row->product_title;
	$this->product_description = $row->product_description;
	$this->product_link = $row->product_link;
	$this->product_rate = $row->product_rate;
	$this->product_price = $row->product_price;
	$this->product_content = $row->product_content;
	break;
      }
    if ($this->product_id != -1)
      return true;
    return false;
  }

  public function insert()
  {
    $data = array(
		  'product_category_id' => $this->product_category_id,
		  'product_user_id'  => $this->product_user_id,
		  'product_title' => $this->product_title,
		  'product_description' => $this->product_description,
		  'product_link' => $this->product_link,
		  'product_rate' => $this->product_rate,
		  'product_price' => $this->product_price,
		  'product_content' => $this->product_content
		  );
    $this->db->insert('product', $data); 
  }
}